package com.liqi.web.controller.info;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.liqi.common.annotation.Log;
import com.liqi.common.core.controller.BaseController;
import com.liqi.common.core.domain.AjaxResult;
import com.liqi.common.enums.BusinessType;
import com.liqi.common.utils.poi.ExcelUtil;
import com.liqi.info.domain.TInfoBmfw;
import com.liqi.info.service.ITInfoBmfwService;
import com.liqi.common.core.page.TableDataInfo;

/**
 * 便民服务Controller
 * 
 * @author zh
 * @date 2022-11-09
 */
@RestController
@RequestMapping("/info/bmfw")
public class TInfoBmfwController extends BaseController
{
    @Autowired
    private ITInfoBmfwService tInfoBmfwService;

    /**
     * 查询便民服务列表
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInfoBmfw tInfoBmfw)
    {
        startPage();
        List<TInfoBmfw> list = tInfoBmfwService.selectTInfoBmfwList(tInfoBmfw);
        return getDataTable(list);
    }

    /**
     * 导出便民服务列表
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:export')")
    @Log(title = "便民服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInfoBmfw tInfoBmfw)
    {
        List<TInfoBmfw> list = tInfoBmfwService.selectTInfoBmfwList(tInfoBmfw);
        ExcelUtil<TInfoBmfw> util = new ExcelUtil<TInfoBmfw>(TInfoBmfw.class);
        util.exportExcel(response, list, "便民服务数据");
    }

    /**
     * 获取便民服务详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tInfoBmfwService.selectTInfoBmfwById(id));
    }

    /**
     * 新增便民服务
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:add')")
    @Log(title = "便民服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInfoBmfw tInfoBmfw)
    {
        return toAjax(tInfoBmfwService.insertTInfoBmfw(tInfoBmfw));
    }

    /**
     * 修改便民服务
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:edit')")
    @Log(title = "便民服务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInfoBmfw tInfoBmfw)
    {
        return toAjax(tInfoBmfwService.updateTInfoBmfw(tInfoBmfw));
    }

    /**
     * 删除便民服务
     */
    @PreAuthorize("@ss.hasPermi('info:bmfw:remove')")
    @Log(title = "便民服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInfoBmfwService.deleteTInfoBmfwByIds(ids));
    }
}
